using System.Collections.Generic;
using UnityEngine;
using Framework;
using StateNode;

public enum GameProgress
{
    Main = 1, Progress1 = 2
}
public class ProgressController : GameSingleton<ProgressController>, IGameUpdater
{
    #region 主要的事件清单
    Dictionary<int, IStateNode> StateNotesDic = new Dictionary<int, IStateNode>();
    List<IStateNode> stateNotes;
    private IStateNode tempNode;//现在的状态
    /// <summary>
    /// 把需要所有阶段都进行的GameUpdate放这里
    /// </summary>
    private IStateNode nodeAlwaysAwake;//永远持续进行的node
    #endregion
    #region 初始化和刷新
    public override void Init()
    {
        base.Init();
        stateNotes = new List<IStateNode>()
        {
            new GameMainProgress(),new GameProgress1()
        };
        foreach (var note in stateNotes)
        {
            StateNotesDic.Add(note.ID, note);
        }
        tempNode = StateNotesDic[0];//设置初始
        tempNode.Enter();
    }
    public void GameUpdate(float deltaTime)
    {
        tempNode.GameUpdate(deltaTime);
        nodeAlwaysAwake.GameUpdate(deltaTime);
    }
    #endregion
    #region 公有函数
    public void Next()
    {
        tempNode.Exit();
        tempNode = StateNotesDic[tempNode.GetNextState()];
        tempNode.Enter();
    }
    #endregion
}